<!DOCTYPE html>                                                                 
                                        
<script src="../resources/common.js"></script>                                  
                                        
<script src="../../../resources/js-test.js"></script>  

<form name=alpha>
<input type="radio" name="fruit" id="apple"><br>
<input type="radio" name="fruit" id="banana"><br>
<input type="radio" name="fruit" id="cherry"><br>
<input type="radio" name="fruit" form=beta id="tomato"><br>
<input type="radio" name="fruit" form=beta id="delta"><br>
</form>
<form name=beta>
    <input type="radio" name="fruit" id="pumpkin"><br>
</form>
<input type="radio" name="fruit" form=alpha id="cucumber"><br>
                                      
<script> 
document.alpha.insertBefore(document.beta, document.alpha.fruit[2]);                                   
description('Tests after pressing last radio button in the list, on pressing downkey it selects back first radio button');

clickElement(document.getElementById('cherry'));                                  
shouldBeTrue('document.getElementById("cherry").checked');
                 
eventSender.keyDown('ArrowDown');                                                    
shouldBeTrue('document.getElementById("apple").checked');

eventSender.keyDown('ArrowUp');                                                    
shouldBeTrue('document.getElementById("cherry").checked');


clickElement(document.getElementById('cucumber'));
shouldBeTrue('document.getElementById("cucumber").checked');

eventSender.keyDown('ArrowDown');
shouldBeTrue('document.getElementById("tomato").checked');

eventSender.keyDown('ArrowUp');
shouldBeTrue('document.getElementById("cucumber").checked');

clickElement(document.getElementById('pumpkin'));
shouldBeTrue('document.getElementById("pumpkin").checked');

eventSender.keyDown('ArrowDown');
shouldBeTrue('document.getElementById("pumpkin").checked');

eventSender.keyDown('ArrowUp');
shouldBeTrue('document.getElementById("pumpkin").checked');

</script>                                                                                                   
